<?php 
session_start();include "conn.php";
?>
<?php  include("admin.php");?>

<?php
//文件名。。。
 $webname="beijin";
 $linkname="bg_admin"; 
?>
 
 
 
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>網站管理系統</title>
<LINK REL="stylesheet" HREF="css/style.css" TYPE="text/css">
<LINK REL="stylesheet" HREF="css/main.css" TYPE="text/css">

<script src="js/FancyZoom.js" language="JavaScript" type="text/javascript"></script>
<script src="js/FancyZoomHTML.js" language="JavaScript" type="text/javascript"></script>
<body onLoad="setupZoom();">


<?php 
$id=make_safe($_GET["id"]);

//echo $data;
$action=make_safe($_GET["action"]);
$BigClassName=make_safe($_POST["BigClassName"]);
if($BigClassName==""){$BigClassName=make_safe($_GET["BigClassName"]);}
$enBigClassName=make_safe($_POST["enBigClassName"]);
$SmallClassName=make_safe($_POST["SmallClassName"]);
if($SmallClassName==""){$SmallClassName=make_safe($_GET["SmallClassName"]);}
$title=make_safe($_POST["title"]);
$entitle=make_safe($_POST["entitle"]);
$price=make_safe($_POST["price"]);

$addtime=make_safe($_POST["addtime"]);
$user=make_safe($_POST["user"]);
$content=$_POST["content"];
$encontent=$_POST["encontent"];
$oldimages=make_safe($_POST["oldimages"]);
$oldimages2=make_safe($_POST["oldimages2"]);
$oldimages3=make_safe($_POST["oldimages3"]);
$oldimages4=make_safe($_POST["oldimages4"]);
$oldimages5=make_safe($_POST["oldimages5"]);
$oldimages6=make_safe($_POST["oldimages6"]);
$oldimages7=make_safe($_POST["oldimages7"]);
$oldimages8=make_safe($_POST["oldimages8"]);


include("check.php");




$path = 'upfiles/'. $_FILES['images']['name'];
$type=strstr($path,'.');
$path2 ='upfiles/'.$data."1".$type;

$path3 = 'upfiles/'. $_FILES['images2']['name'];
$type3=strstr($path3,'.');
$path4 ='upfiles/'.$data."2".$type3;

$path5 = 'upfiles/'. $_FILES['images3']['name'];
$type5=strstr($path5,'.');
$path6 ='upfiles/'.$data."3".$type5;

$path7 = 'upfiles/'. $_FILES['images4']['name'];
$type7=strstr($path7,'.');
$path8 ='upfiles/'.$data."4".$type7;

$path9 = 'upfiles/'. $_FILES['images5']['name'];
$type9=strstr($path9,'.');
$path10 ='upfiles/'.$data."5".$type9;

$path11 = 'upfiles/'. $_FILES['images6']['name'];
$type11=strstr($path11,'.');
$path12 ='upfiles/'.$data."6".$type11;

$path13 = 'upfiles/'. $_FILES['images7']['name'];
$type13=strstr($path13,'.');
$path14 ='upfiles/'.$data."7".$type13;

$path15 = 'upfiles/'. $_FILES['images8']['name'];
$type15=strstr($path15,'.');
$path16 ='upfiles/'.$data."8".$type15;


$type=strtolower($type); 
$type3=strtolower($type3); 
$type5=strtolower($type5); 
$type7=strtolower($type7); 
$type9=strtolower($type9); 
$type11=strtolower($type11); 
$type13=strtolower($type13);
$type15=strtolower($type15);



//增加数据
if($action=="add"){
	
if($type==".jpg" or  $type==".JPG" or $type==".jpge" or $type==".gif" or $type==".doc" or $type==".xls" or $type==".bmp" or $type==".pdf" ){
move_uploaded_file($_FILES['images']['tmp_name'],$path2);
}//上传图片
else
{
$path2="";
}


if($type3==".jpg" or  $type3==".JPG" or $type3==".jpge" or $type3==".gif" or $type3==".doc" or $type3==".xls" or $type3==".bmp" or $type3==".pdf" ){
move_uploaded_file($_FILES['images2']['tmp_name'],$path4);
}//上传图片
else
{
$path4="";
}

if($type5==".jpg" or  $type5==".JPG" or $type5==".jpge" or $type5==".gif" or $type5==".doc" or $type5==".xls" or $type5==".bmp" or $type5==".pdf" ){
move_uploaded_file($_FILES['images3']['tmp_name'],$path6);
}//上传图片
else
{
$path6="";
}


if($type7==".jpg" or  $type7==".JPG" or $type7==".jpge" or $type7==".gif" or $type7==".doc" or $type7==".xls" or $type7==".bmp" or $type7==".pdf" ){
move_uploaded_file($_FILES['images4']['tmp_name'],$path8);
}//上传图片
else
{
$path8="";
}


if($type9==".jpg" or  $type9==".JPG" or $type9==".jpge" or $type9==".gif" or $type9==".doc" or $type9==".xls" or $type9==".bmp" or $type9==".pdf" ){
move_uploaded_file($_FILES['images5']['tmp_name'],$path10);
}//上传图片
else
{
$path10="";
}

if($type11==".jpg" or  $type11==".JPG" or $type11==".jpge" or $type11==".gif" or $type11==".doc" or $type11==".xls" or $type11==".bmp" or $type11==".pdf" ){
move_uploaded_file($_FILES['images6']['tmp_name'],$path12);
}//上传图片
else
{
$path12="";
}
 
if($type13==".jpg" or  $type13==".JPG" or $type13==".jpge" or $type13==".gif" or $type13==".doc" or $type13==".xls" or $type13==".bmp" or $type13==".pdf" ){
move_uploaded_file($_FILES['images7']['tmp_name'],$path14);
}//上传图片
else
{
$path14="";
}

 
if($type15==".jpg" or  $type15==".JPG" or $type15==".jpge" or $type15==".gif" or $type15==".doc" or $type15==".xls" or $type15==".bmp" or $type15==".pdf" ){
move_uploaded_file($_FILES['images8']['tmp_name'],$path16);
}//上传图片
else
{
$path16="";
}

$sql="Insert Into ".$webname." (title,entitle,price,BigClassName,enBigClassName,SmallClassName,content,encontent,addtime,images,images2,images3,images4,images5,images6,images7,images8) Values('$title','$entitle','$price','$BigClassName','$enBigClassName','$SmallClassName','$content','$encontent','$addtime','$path2','$path4','$path6','$path8','$path10','$path12','$path14','$path16')";
$result=mysql_query($sql);

echo "<script> alert('增加成功！');window.location.href='".$webname."_manage.php';</script>";
}


//修改数据
if($action=="xiugai"){
 
if($type==".jpg" or  $type==".JPG" or $type==".jpge" or $type==".gif" or $type==".doc" or $type==".xls" or $type==".bmp" or $type==".pdf" ){
move_uploaded_file($_FILES['images']['tmp_name'],$path2);//上传图片
if($oldimages!=""){unlink($oldimages);}//删除旧图片
}
else
{
$path2=$oldimages;
}


if($type3==".jpg" or  $type3==".JPG" or $type3==".jpge" or $type3==".gif" or $type3==".doc" or $type3==".xls" or $type3==".bmp" or $type3==".pdf" ){
move_uploaded_file($_FILES['images2']['tmp_name'],$path4);//上传图片
if($oldimages2!=""){unlink($oldimages2);}//删除旧图片
}
else
{
$path4=$oldimages2;
}

if($type5==".jpg" or  $type5==".JPG" or $type5==".jpge" or $type5==".gif" or $type5==".doc" or $type5==".xls" or $type5==".bmp" or $type5==".pdf" ){
move_uploaded_file($_FILES['images3']['tmp_name'],$path6);//上传图片
if($oldimages3!=""){unlink($oldimages3);}//删除旧图片
}
else
{
$path6=$oldimages3;
}
 
if($type7==".jpg" or  $type7==".JPG" or $type7==".jpge" or $type7==".gif" or $type7==".doc" or $type7==".xls" or $type7==".bmp" or $type7==".pdf" ){
move_uploaded_file($_FILES['images4']['tmp_name'],$path8);//上传图片
if($oldimages4!=""){unlink($oldimages4);}//删除旧图片
}
else
{
$path8=$oldimages4;
}

if($type9==".jpg" or  $type9==".JPG" or $type9==".jpge" or $type9==".gif" or $type9==".doc" or $type9==".xls" or $type9==".bmp" or $type9==".pdf" ){
move_uploaded_file($_FILES['images5']['tmp_name'],$path10);//上传图片
if($oldimages5!=""){unlink($oldimages5);}//删除旧图片
}
else
{
$path10=$oldimages5;
}
 
if($type11==".jpg" or  $type11==".JPG" or $type11==".jpge" or $type11==".gif" or $type11==".doc" or $type11==".xls" or $type11==".bmp" or $type11==".pdf" ){
move_uploaded_file($_FILES['images6']['tmp_name'],$path12);//上传图片
if($oldimages6!=""){unlink($oldimages6);}//删除旧图片
}
else
{
$path12=$oldimages6;
}

if($type13==".jpg" or  $type13==".JPG" or $type13==".jpge" or $type13==".gif" or $type13==".doc" or $type13==".xls" or $type13==".bmp" or $type13==".pdf" ){
move_uploaded_file($_FILES['images7']['tmp_name'],$path14);//上传图片
if($oldimages7!=""){unlink($oldimages7);}//删除旧图片
}
else
{
$path14=$oldimages7;
}
 
if($type15==".jpg" or  $type15==".JPG" or $type15==".jpge" or $type15==".gif" or $type15==".doc" or $type15==".xls" or $type15==".bmp" or $type15==".pdf" ){
move_uploaded_file($_FILES['images8']['tmp_name'],$path16);//上传图片
if($oldimages8!=""){unlink($oldimages8);}//删除旧图片
}
else
{
$path16=$oldimages8;
}





if($query=mysql_query("update ".$webname." set title='$title',entitle='$entitle',price='$price',BigClassName='$BigClassName',enBigClassName='$enBigClassName',SmallClassName='$SmallClassName',content='$content',encontent='$encontent',addtime='$addtime',images='$path2',images2='$path4',images3='$path6',images4='$path8',images5='$path10',images6='$path12',images7='$path14',images8='$path16' where id='$id'"))

{
   echo "<script>alert('資料修改成功！');window.location.href='".$webname."_manage.php?BigClassName=".$BigClassName."&SmallClassName=".$SmallClassName."&page=".$page."';</script>";
 }
 
 else
  {
   echo "<script>alert('資料修改失敗！');window.location.href='".$webname."_manage.php?BigClassName=".$BigClassName."&SmallClassName=".$SmallClassName."&page=".$page."';</script>";
  }
}
?>





<script language="javascript"> 



function Checker(){ 


  
// document.write(document.form2.id.length)
  
  
  
   //if(document.form2.yaoyun.value==""){document.write("您按了确认！") }
   
   //  document.write("您按了确认！") 

   

document.form2.items.value = "";         //设置隐藏域的值为空
if ( !document.form2.id.length ) {      //只有一个复选框，form2.item.length = undefined



	if ( document.form2.id.checked ){
	document.form2.items.value = document.form2.id.value; 
	
	
	} 
}else { 

	var temp="";
	for ( i = 0 ; i < document.form2.id.length ; i++ ){ 
		if ( document.form2.id[i].checked ){       //复选框中有选中的框 
			temp=temp+document.form2.id[i].value+",";   //将数组中的元素使用","分隔
		}	 

	} 
	temp=temp.substring(0,temp.length-1);     //去除字符串末尾多余的","
	document.form2.items.value = temp;    //将变量赋值给隐藏域
	
//	document.write(document.form2.items.value)
} 
} 
</script>  <script language="javascript">
function CheckAll(elementsA,elementsB)
{
	var len = elementsA;
	if(len.length > 0)
	{
		for(i=0;i<len.length;i++)
		{
			elementsA[i].checked = true;
		}
		if(elementsB.checked ==false)
		{
			for(j=0;j<len.length;j++)
			{
				elementsA[j].checked = false;
			}
		}
	}
	else
	{
		len.checked = true;
		if(elementsB.checked == false)
		{
			len.checked = false;
		}
	}
}
</script>



<SCRIPT language=javascript>

function ConfirmDel()
{
   if(confirm("確定要刪除選擇的訊息嗎？一旦刪除將不能恢複！"))
     return true;
   else
     return false;
	 
}

</SCRIPT>






<table width="98%" border="0" class="table2">
  <tr>
    <td>產品展示 - 管理全部產品</td>
  </tr>
</table>




<table width="98%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="100%" align="center" valign="top">
      <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#000000" class="border">
        
		
	
      </table>
	  
      <form name="form2" method="Post" action="product_del.php" onSubmit="Checker()">
        <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
          <tr bgcolor="#A5D269"> 
            <td width="853" height="25" bgcolor="#E4F2FF"><a href="<?php echo $webname;?>_manage.php">&nbsp;訊息管理</a> &gt;&gt; 
             <?php if($BigClassName==""){echo "所有訊息";}else{echo $BigClassName;}?> <?php if($SmallClassName!=""){echo "&gt;&gt;",$SmallClassName;}?></td>
			  
			 
			  <?php 
		
		 $title2=make_safe($_GET["title"]);
   if($page){
    $page_size=10;
	$sql="select count(*) as total from ".$webname." where id>0 ";
	if($BigClassName!=""){$sql=$sql." and BigClassName='$BigClassName'";}
	if($SmallClassName!=""){$sql=$sql." and SmallClassName='$SmallClassName'";}
	if($title2!=""){$sql=$sql." and title like '%".$title2."%'";}
	$result=mysql_query($sql);
    $message_count=mysql_result($result,0,"total");
    $page_count=ceil($message_count/$page_size);	
    $offset=($page-1)*$page_size;	
	$sql="select * from ".$webname." where id>0 ";
	if($BigClassName!=""){ $sql=$sql."and BigClassName='$BigClassName'";}
	if($SmallClassName!=""){$sql=$sql." and SmallClassName='$SmallClassName'";}
	if($title2!=""){$sql=$sql." and title like '%".$title2."%'";}
	$sql=$sql."order by id desc limit $offset, $page_size";
	$result=mysql_query($sql);
	?>
            <td width="113" bgcolor="#E4F2FF">&nbsp;<?php if($title2){echo "共找到 ".$message_count." 條訊息";} ?></td>
          </tr>
        </table>
       
        <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000" class="border" style="word-break:break-all">
          <tr bgcolor="#A5D269" class="title"> 
            <td width="55" height="25" align="center" bgcolor="#E4F2FF">選擇</td>
            <td width="52"  height="25" align="center" bgcolor="#E4F2FF">id</td>
            <td width="208" align="center" bgcolor="#E4F2FF" >標題</td>
            <td width="90" align="center" bgcolor="#E4F2FF" >會員價</td>
            <td width="226" align="center" bgcolor="#E4F2FF" >所屬大類</td>
            <td width="135" align="center" bgcolor="#E4F2FF" >上傳圖片</td>
            <td width="99" align="center" bgcolor="#E4F2FF" >加入時間</td>
            <td width="95" align="center" bgcolor="#E4F2FF" >操作</td>
          </tr>
         
	<?php
	while ($row=mysql_fetch_object($result)){
	?>
          <tr class="tdbg"> 
            <td width="55" height="22" align="center" bgcolor="#FFFFFF"> 
            <input name="id" type="checkbox" id="id" value="<?php echo $row->id;?>">            </td>
            <td width="52" align="center" bgcolor="#FFFFFF"><?php echo $row->id;?></td>
            <td  bgcolor="#FFFFFF"><div align="center"><?php echo $row->title;?></div></td>
            <td  bgcolor="#FFFFFF"><div align="center"><?php echo $row->price;?></div></td>
            <td  bgcolor="#FFFFFF">
            <div align="center"><?php echo $row->BigClassName;?></div></td>
            <td  bgcolor="#FFFFFF">
            
           
            
            
            
              <div align="center"><?php if($row->images!=""){ ?>
              
              
              
                <a href="<?php echo "../".$row->images;?>"><img alt=""height="47" src="<?php echo "../".$row->images;?>" width="70" border="0"></a>
            <?php }?></div></td>
            <td align="center" bgcolor="#FFFFFF"><?php echo $row->addtime;?></td>
            <td width="95" align="center" bgcolor="#FFFFFF"><a href="<?php echo $webname;?>_xiugai.php?id=<?php echo $row->id;?>&BigClassName=<?php echo urlencode($row->BigClassName);?>&enBigClassName=<?php echo urlencode($row->enBigClassName);?>&page=<?php echo $page;?>">修改</a>
			<a href="<?php echo $webname;?>_del.php?id=<?php echo $row->id;?>&action=del" onClick="return ConfirmDel();">刪除</a></td>
          </tr>
        <?php }}?>
		
          <tr>
            <td height="100%" colspan="16" bgcolor="#DADDFE" scope="col">
              <div align="center">總共&nbsp;<?php echo $message_count;?> 條記錄&nbsp;&nbsp;頁次：
			  <?php 
			  $BigClassName=make_safe($_GET["BigClassName"]);
			  $BigClassName=urlencode($BigClassName);
			  if($page!=1)
				   {
				     echo  "<a href=?page=1&BigClassName=".$BigClassName.">首頁</a>&nbsp;&nbsp;&nbsp;";
					 echo "<a href=?page=".($page-1)."&BigClassName=".$BigClassName.">上一頁</a>&nbsp;&nbsp;&nbsp;";
				   } echo $page;?> / <?php echo $page_count;?> 頁&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
              <?php
	  		  
				  if($page<$page_count)
				   {
				        echo "<a href=?page=".($page+1)."&BigClassName=".$BigClassName.">下一頁</a>&nbsp;&nbsp;&nbsp;";
				        echo  "<a href=?page=".$page_count."&BigClassName=".$BigClassName.">尾頁</a>&nbsp;&nbsp;&nbsp;&nbsp;";
				   
				   }
				   
				 
				?>
                 &nbsp;&nbsp;&nbsp;跳轉到
                 <script type="text/javascript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
                 <select name="jumpMenu" id="jumpMenu" onChange="MM_jumpMenu('self',this,0)">
                 
                 <?php 
				 for($i=1;$i<=$page_count;$i++){
				 ?>
                   <option value="?page=<?php echo $i;?>" <?php if($page==$i){echo "selected";}?>><?php echo $i;?></option>
                   <?php }?>
                   </select>頁</div>               
            </span></td>
          </tr>
        </table>
        <table width="620" border="0" cellpadding="0" cellspacing="0">
          <tr> <input type="hidden" name="items" value="<?php echo $item; ?>">
            <td width="250" height="30"><input name="chk_all" type="checkbox" id="chk_all" value="checkbox" onClick="CheckAll(this.form.id,this.form.chk_all)">
              選擇本頁顯示的所有訊息</td>
            <td><input name="submit" type='submit' value='刪除選擇的訊息' onClick="return ConfirmDel();"> 
             </td>
          </tr>
        </table>
        
      </form>
      <br> <table width="620" border="0" cellpadding="0" cellspacing="0" class="border">
        <tr class="tdbg"> 
          <form name="searchsoft" method="get" action="<?php echo $webname;?>_manage.php">
            <td height="30"> <strong>尋找訊息：</strong> <input name="title" type="text" class=smallInput id="Title3" size="20" maxlength="50"> 
              <input name="Query" type="submit" id="Query" value="查 詢"> &nbsp;&nbsp;請輸入訊息名稱。如果爲空，則尋找所有訊息。</td>
          </form>
        </tr>
      </table></td>
  </tr>
</table>

